import java.util.Scanner;

public class BinarySearch {
    public static void main(String[] args) {
        int[] arr = {3,5,7,9,13,24,34,55,57,60,64,72};
        System.out.println("请输入你要查找的数字");

        //输入操作
        Scanner read = new Scanner(System.in);
        int input = read.nextInt();
        //二分查找
        int left = 0,right = arr.length-1;
        int mid = 0;
        while(left <= right)
        {
            mid = (left+right)/2;
            if(input == arr[mid])
            {
                break;
            }
            else if(input < arr[mid])
            {
                right = mid -1;
            }
            else
            {
                left = mid+1;
            }
        }
        //判断是否找到
        if(left <= right)
        {
            System.out.println("找到了，这个元素的索引是："+mid);
        }
        else
        {
            System.out.println("该元素不存在");
        }
    }
}
